package com.ikkong.biz.meta.intercept;

import com.google.common.collect.BiMap;
import com.ikkong.biz.service.ClassesService;
import com.ikkong.biz.service.impl.ClassesServiceImpl;
import com.ikkong.core.aop.AopContext;
import com.ikkong.core.jfinal.ext.kit.JStrKit;
import com.ikkong.core.meta.PageIntercept;
import com.ikkong.core.toolbox.Func;
import com.ikkong.core.toolbox.support.BladePage;

import java.util.List;
import java.util.Map;

public class ParentIntercept extends PageIntercept {
    ClassesService service = new ClassesServiceImpl();
	/**
	 * 查询后附加字典项
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void queryAfter(AopContext ac) {
		BladePage<Map<String, Object>> page = (BladePage<Map<String, Object>>) ac.getObject();
		List<Map<String, Object>> list = page.getRows();
        Map<Integer, String> maps = service.allClassNames();
        for (Map<String, Object> map : list) {
            map.put("position", Func.getDictName(1003, map.get("position")));
		}
	}

    @Override
    public void queryBefore(AopContext ac) {
        String where = ac.getCtrl().getPara("where");
        if (JStrKit.notBlank(where)){
            if (where.indexOf("is_graduate")<0){
                ac.setCondition(" and is_graduate =1 ");
            }
        }else {
            ac.setCondition(" and is_graduate =1 ");
        }
    }
}
